How should I organize my C# classes? [closed]

Posted by oscar.fimbres on Stack Overflow See other posts from Stack Overflow or by oscar.fimbres
Published on 2011-07-24T00:15:48Z Indexed on 2012/09/27 3:38 UTC
Read the original article Hit count: 213

Filed under:
|
|
|

I'm creating an email generator system. I'm creating some clases and I'm trying to make things right.

By the time, I have created 5 classes. Look at the class diagram:

enter image description here

I'm going to explain you each one.

  • Person. It's not a big deal. Just have two constructors: Person(fname, lname1, lname2) and Person(token, fname, lname1, lname2). Note that email property stays without value.

  • StringGenerator. This is a static class and it has only a public function: Generate. The function receives a Person class and it will return a list of patterns for the email.

  • MySql. It contains all the necessary to connect to a database.

  • Database. This class inherits from MySql class. It has particular functions for the database.

This gets all the registries from a table (function GetPeople) and return a List. Each person from the list contains all data except Email.

Also it can add records (List but this must contains an available email). An available email is when an email doesn't have another person. For that reason, I have a method named ExistsEmail.

  • Container. This is the class which is causing me some problems. It's like a temporary container. It supposed to have a people list from GetPeople (in Database class) and for each person it adds, it must generate a list of possible names (StringGenerator.Generate), then it selects one of the list and it must check out if exists in the database or in the same container.

As I told above this is temporal, it may none of the possible emails is available. So the user can modify or enter a custom email available and update the list in this container. When all the email's people are available, it sends a list to add in the database,

It must have a Flush method, to insert all the people in the database.

I'm trying to design correct class. I need a little help to improve or edite the classes, because I want to separate the logic and visual, and learn of you.

I hope you've been able to understand me. Any question or doubt, please let me know. Anyway, I attached the solution here to better understand it: http://www.megaupload.com/?d=D94FH8GZ

© Stack Overflow or respective owner

Related posts about c#

Related posts about oop